package com.cd.university.config.exception;

import com.cd.university.common.RestResult;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author 陈栋
 * @create 2021/9/17 12:00
 */
@RestControllerAdvice(basePackages = {"com.cd.university.controller"})
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    private RestResult globalException(Exception e) {
        e.printStackTrace();
        String msg = e.getMessage();
        if (e.getMessage()==null) {
            msg = "空指针了哦！看看是不是你的参数用问题";
        }
        return RestResult.failure(msg);
    }
}
